#ifndef TABLECURDTEMPLATE_H
#define TABLECURDTEMPLATE_H

#include "precomp.h"
//#include <QWidget>
//#include <QTableView>
//#include <QLabel>
//#include <QComboBox>
//#include <QLineEdit>
//#include <QDateEdit>
//#include <QPushButton>
//#include <QHBoxLayout>
//#include <QVBoxLayout>
//#include <QSpacerItem>
//#include <QStandardItemModel>
//#include <QSqlDatabase>
//#include <QSqlError>
//#include <QSqlQueryModel>
//#include <QSqlQuery>
#include "qpagebar.h"

class DNSuffixWhoisMappingDlg ;

class TableCURDTemplate : public QWidget
{
    Q_OBJECT
public:
    explicit TableCURDTemplate(QWidget *parent = nullptr);
    ~TableCURDTemplate();

    int m_pageSize=0;
    int m_totalRecs;
    QString m_sqlCols,m_sqlWhere,m_sqlOrder,m_sqlTable;
    QSqlDatabase m_db;
    QStringList m_strColsName;
    DNSuffixWhoisMappingDlg *m_dlg;
    QVector<int>  m_columnWidth;

    void initUi();
    void initModel();
    void setFilterControl(bool edit,bool comb,bool sdate,bool edate);
    //void createDomainInfoRightPopMenu();
    //QList<QStandardItem*> createDomainInfoRow(const DomainInfo &domainInfo);
//    void dealRecvDataFromServer( QByteArray data);
//    bool matchWhoisServerInfo(QString domainStr,QString & addrStr,int & port);
    //DomainDetailInfo getDomainDetailInfoById(int domainId);
//    void clientSocketRequest(QString sendMsg,QString ipAddr,int port);
//    void onRefleshDomainTable(int categoryId);
//    void setTableHeaderLabels(QStringList strHeaderLabels);

private:
    QTableView *m_tableView;
    QWidget *m_filterWidget,*m_actWidget,*m_showWidget;
    QLabel *m_lableEdit,*m_labelComb,*m_labelStart,*m_labelEnd;
    bool m_editEnable,m_combEnable,m_sdateEnable,m_edateEnable;
    QLineEdit *m_editText;
    QComboBox *m_combSelect;
    QDateEdit *m_dateStart,*m_dateEnd;
    QPushButton *m_btnReset,*m_btnQry,*m_btnAdd,*m_btnDel,*m_btnMod,*m_btnExp;
    QHBoxLayout *m_hFilterLayout,*m_hActLayout;
    QVBoxLayout *m_vShowLayout,*m_vLayout;
    QPageBar  *m_pageBar;
    QSpacerItem *m_actSpacer,*m_filterSpacer;
    QStandardItemModel *m_tableModel;


    bool getTabTotalRecs(int &totalnum);
//    bool getTabColumnsName(QStringList &strColumnsName);

signals:

private slots:
    void slotShowTabInfoByPage(int indexId,int curPage);
    void slotAddRecord();
    void slotDelRecord();
    void slotModRecord();
    void slotExpRecord();
    void slotQryRecords();
    void slotResetFilter();
};

#endif // TABLECURDTEMPLATE_H
